package org.snow.maplesnowsniffer;

import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
import javax.swing.JOptionPane;
import org.snow.odinms.HexTool;
import org.snow.odinms.MapleJob;
import org.snow.odinms.MapleSkinColor;
import org.snow.odinms.RecvPacketOpcode;
import org.snow.odinms.SeekableLittleEndianAccessor;
import org.snow.odinms.SendPacketOpcode;

/**
 *
 * @author  Raz
 */
public class MaplePacketStructureViewer extends javax.swing.JFrame {

	private static final long serialVersionUID = 4520084963404662491L;
	private static final String NEW_LINE = "\r\n";
	private MaplePacketRecord packetRecord;
	private SeekableLittleEndianAccessor slea;
	private StringBuilder builder;
	private boolean send;

	/** Creates new form MaplePacketStructureViewer */
	public MaplePacketStructureViewer() {
            // <editor-fold defaultstate="collapsed" desc="LookAndFeelInfo">
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Windows".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MaplePacketStructureViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MaplePacketStructureViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MaplePacketStructureViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MaplePacketStructureViewer.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        // </editor-fold>
		initComponents();
	}

	/** This method is called from within the constructor to
	 * initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is
	 * always regenerated by the Form Editor.
	 */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        closeButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        packetStructureTextArea = new javax.swing.JTextArea();
        copyStructureButton = new javax.swing.JButton();
        packetLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Snow's Packet Structure Viewer");
        setResizable(false);

        closeButton.setText("Đóng");
        closeButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeButtonActionPerformed(evt);
            }
        });

        packetStructureTextArea.setColumns(20);
        packetStructureTextArea.setEditable(false);
        packetStructureTextArea.setRows(5);
        jScrollPane1.setViewportView(packetStructureTextArea);

        copyStructureButton.setText("Copy Cấu Trúc");
        copyStructureButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                copyStructureButtonActionPerformed(evt);
            }
        });

        packetLabel.setText("Packet:");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 384, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(copyStructureButton)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 222, Short.MAX_VALUE)
                        .addComponent(closeButton)
                        .addContainerGap())
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(packetLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)
                        .addGap(203, 203, 203))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(packetLabel)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 237, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(closeButton)
                    .addComponent(copyStructureButton))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
	private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeButtonActionPerformed
		//CLOSE
		setVisible(false);
		dispose();
}//GEN-LAST:event_closeButtonActionPerformed

	private void copyStructureButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyStructureButtonActionPerformed
		//COPY STRUCTURE DATA
		StringSelection stringSelection = new StringSelection(packetStructureTextArea.getText());
		Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
		clipboard.setContents(stringSelection, stringSelection);
		JOptionPane.showMessageDialog(null, "Copied structure-data to clipboard", "Information", JOptionPane.INFORMATION_MESSAGE);
}//GEN-LAST:event_copyStructureButtonActionPerformed

	public MaplePacketRecord getPacketRecord() {
		return packetRecord;
	}

	public void setPacketRecord(MaplePacketRecord packetRecord) {
		this.packetRecord = packetRecord;
	}

	public SeekableLittleEndianAccessor getSlea() {
		return slea;
	}

	public void setSlea(SeekableLittleEndianAccessor slea) {
		this.slea = slea;
	}

	public boolean isSend() {
		return send;
	}

	public void setSend(boolean send) {
		this.send = send;
	}

	public void setPacketLabelText(String s) {
		packetLabel.setText(s);
	}

	public void anazlyePacket() {
		if (slea == null || packetRecord == null || !packetRecord.isDataRecord()) {
			return;
		}
		builder = new StringBuilder();
		if (send) {
			RecvPacketOpcode opcode = RecvPacketOpcode.getByType(slea.readShort());
			handleToServer(opcode);
		} else {
			SendPacketOpcode opcode = SendPacketOpcode.getByType(slea.readShort());
			handleToClient(opcode);
		}
		if (slea.available() > 0) {
			builder.append("\r\nRemaining Bytes : " + slea.available());
		}
		packetStructureTextArea.setText(builder.toString());
                MaplePcaptureGUI.jTextArea1.setText(builder.toString());
	}

	public StringBuilder handleToClient(SendPacketOpcode opcode) {
		builder.append("Header : " + HexTool.getOpcodeToString((short) opcode.getValue()) + " ( " + opcode.name() + " )" + NEW_LINE);
		//<editor-fold defaultstate="collapsed" desc=" Switch Opcode ">
                /*switch (opcode) {
			case PING:
			//case FORCED_MAP_EQUIP:
			//case LUCKSACK_FAIL:
				//NOTHING
				break;
			case SERVERLIST:
				if (slea.available() == 1) {
					builder.append("--END_OF_SERVER_LIST" + NEW_LINE);
					builder.append("END_MARKER - Byte(1) - 0x" + HexTool.toString(slea.readByte()) + NEW_LINE);
				} else {
					builder.append("--SERVER_LIST" + NEW_LINE);
					builder.append("WORLD_ID - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("WORLD_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
					int statusType = slea.readByte();
					builder.append("WORLD_STATUS_TYPE - Byte(1) - " + statusType + "(" + WorldStatusType.getById(statusType).name() + ")" + NEW_LINE);
					builder.append("EVENT_MESSAGE - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
					builder.append("EXP_RATE_MODIFIER - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("EXP_RATE - Byte(1) - " + slea.readByte() + "(rate * 2.6)" + NEW_LINE);
					builder.append("DROP_RATE_MODIFIER - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("EXP_RATE - Byte(1) - " + slea.readByte() + "(rate * 2.6)" + NEW_LINE);
					builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
					int lastChannel = slea.readByte();
					builder.append("LAST_CHANNEL - Byte(1) - " + lastChannel + NEW_LINE);
					for (int i = 1; i <= lastChannel; i++) {
						builder.append("   CHANNEL - " + i + NEW_LINE);
						builder.append("     CHANNEL_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
						builder.append("     LOAD - Int(4) - " + slea.readInt() + NEW_LINE);
						builder.append("     WORLD_ID - Byte(1) - " + slea.readByte() + NEW_LINE);
						builder.append("     CHANNEL_INDEX - Short(2) - " + slea.readShort() + NEW_LINE + NEW_LINE);
					}
					builder.append("TICKS - Short(2) - " + slea.readShort() + NEW_LINE);
				}
				break;
			case SERVERSTATUS:
				builder.append("STATUS - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case SERVER_IP: {
				builder.append("TICKS - Short(2) - " + slea.readShort() + NEW_LINE);
				String ipStr = HexTool.getIpStringFromBytes(slea.read(4));
				builder.append("IP_ADDRESS - InetAdress(4) - " + ipStr + NEW_LINE);
				builder.append("PORT - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("CLIENT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("TICKS - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			}
			case CHANGE_CHANNEL: {
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				String ipStr = HexTool.getIpStringFromBytes(slea.read(4));
				builder.append("IP_ADDRESS - InetAdress(4) - " + ipStr + NEW_LINE);
				builder.append("PORT - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			}
			case CHANNEL_SELECTED:
				builder.append("TICKS - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case SPAWN_NPC_REQUEST_CONTROLLER:
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
			case SPAWN_NPC:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("NPC_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("POS_X - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("POS_Y - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("FACING_LEFT - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("FH - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("RX_0 - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("RX_1 - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);//Is playerNPC
				break;
			case KILL_MONSTER:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("DEATH_ANIMATION - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case FACIAL_EXPRESSION:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("EXPRESSION_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case MOVE_PLAYER:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("TICKS - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("   MOVES_LENGTH - Byte(1) - " + slea.readByte() + NEW_LINE);
				//SERIALIZE MOVEMENT
				break;
			case CHATTEXT:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("WHITE_BG - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("CHAT_TEXT - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("BUBBLE_ONLY - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case COOLDOWN:
				builder.append("SKILL_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("TIME - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case REACTOR_DESTROY:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("POS_X - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("POS_Y - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case OPEN_NPC_SHOP:
				builder.append("SHOP_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				int size = slea.readShort();
				builder.append("   ITEMS_LENGTH - Short(2) - " + size + NEW_LINE);
				for (int i = 0; i < size; i++) {
					int itemid = slea.readInt();
					builder.append("     ITEM - Int(4) - " + itemid + NEW_LINE);
					builder.append("     PRICE - Int(4) - " + slea.readInt() + NEW_LINE);
					if (!isRechargable(itemid)) {
						builder.append("       STACK_SIZE - Short(2) - " + slea.readShort() + NEW_LINE);
						builder.append("       ITEM_BUYABLE - Short(2) - " + slea.readShort() + NEW_LINE + NEW_LINE);
					} else {
						builder.append("       TICKS - Short(2) - " + slea.readShort() + NEW_LINE);
						builder.append("       TICKS - Int(4) - " + slea.readInt() + NEW_LINE);
						builder.append("       TICKS - Short(2) - " + ((Short) slea.readShort()).doubleValue() + NEW_LINE);//
						builder.append("       SLOT_MAX - Short(2) - " + slea.readShort() + NEW_LINE + NEW_LINE);
					}
				}
				break;
			case CONFIRM_SHOP_TRANSACTION:
				builder.append("CODE - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case SHOW_SCROLL_EFFECT:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				int type = slea.readShort();
				builder.append("SUCCESS_TYPE - Short(2) - " + slea.readShort() + "(");
				switch (type) {
					case 0:
						builder.append("FAIL )" + NEW_LINE);
						break;
					case 1:
						builder.append("SUCCESS )" + NEW_LINE);
						break;
					case 256:
						builder.append("CURSE )" + NEW_LINE);
						break;
				}
				builder.append("LEGENDARY_SPIRIT - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case REMOVE_PLAYER_FROM_MAP:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case REMOVE_ITEM_FROM_MAP:
				int animation = slea.readByte();
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				if (animation >= 2) {
					builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
					if (slea.available() > 0) {
						builder.append("PET_INDEX - Byte(1) - " + slea.readByte() + NEW_LINE);
					}
				}
				break;
			case CHAR_NAME_RESPONSE:
				builder.append("CHARACTER_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("NAME_USED - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case DELETE_CHAR_RESPONSE:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case CHAR_INFO:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("LEVEL - Byte(1) - " + slea.readByte() + NEW_LINE);
				MapleJob job = MapleJob.getById(slea.readShort());
				builder.append("JOB - Short(2) - " + job.getId() + "(" + job.name() + ")" + NEW_LINE);
				builder.append("FAME - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("IS_MARRIED - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("GUILD_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("GUILD_ALLIANCE_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("IS_SELF - Byte(1) - " + slea.readByte() + NEW_LINE);
				//TODO REST
				break;
			case SHOW_FOREIGN_EFFECT:
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				if (slea.available() == 1) {
					builder.append("EFFECT - Byte(1) - " + slea.readByte() + NEW_LINE);
				}
				if (slea.available() > 0) {
					builder.append("IS_CASTER - Byte(1) - " + slea.readByte() + NEW_LINE);
				}
				if (slea.available() == 4) {
					builder.append("SKILL_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				}
				if (slea.available() == 1) {
					builder.append("LEVEL - Byte(1) - " + slea.readByte() + NEW_LINE);
				}
				break;
			case UPDATE_SKILLS:
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("TICKS - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("SKILL_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("LEVEL - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("MASTER_LEVEL - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case SHOW_QUEST_COMPLETION:
				builder.append("QUEST_ID - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case KEYMAP:
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				while (slea.available() > 4) {
					builder.append("   BINDING_TYPE - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("   BINDING_ACTION - Int(4) - " + slea.readInt() + NEW_LINE + NEW_LINE);
				}
				break;
			case WHISPER: {
				byte mode = slea.readByte();
				builder.append("COMMAND - Byte(1) - " + mode + " - UNKNOWN" + NEW_LINE);
				//TODO
				break;
			}
			case SHOW_MONSTER_HP:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("REMAINING_HP_PERCENT - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case BOSS_ENV:
				 {
					int command = slea.readByte();
					builder.append("COMMAND - Byte(1) - " + command + NEW_LINE);
					switch (command) {
						case 5:
							builder.append("--SHOW_BOSS_HP" + NEW_LINE);
							builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
							builder.append("HP - Int(4) - " + slea.readInt() + NEW_LINE);
							builder.append("MAX_HP - Int(4) - " + slea.readInt() + NEW_LINE);
							builder.append("TAG_COLOR - Byte(1) - " + slea.readByte() + NEW_LINE);
							builder.append("TAG_BG_COLOR - Byte(1) - " + slea.readByte() + NEW_LINE);
							break;
					}
				}
				break;
			case FAME_RESPONSE:
				 {
					int command = slea.readByte();
					builder.append("COMMAND - Byte(1) - " + command + NEW_LINE);
					switch (command) {
						case 5:
							builder.append("--RECEIVE_FAME" + NEW_LINE);
							builder.append("CHARACTER_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
							builder.append("MODE - Byte(1) - " + slea.readByte() + NEW_LINE);
							break;
						case 0:
							builder.append("--GIVE_FAME" + NEW_LINE);
							builder.append("CHARACTER_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
							builder.append("MODE - Byte(1) - " + slea.readByte() + NEW_LINE);
							builder.append("NEW_FAME - Short(2) - " + slea.readShort() + NEW_LINE);
							builder.append("TICKS - Short(2) - " + slea.readShort() + NEW_LINE);
							break;
						default:
							builder.append("--FAME_ERROR_MESSAGE" + NEW_LINE);
							break;
					}
				}
				break;
			case CHARLIST:
				builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
				int characters = slea.readByte();
				builder.append("CHARACTERS - Byte(1) - " + characters + NEW_LINE);
				for (int i = 0; i < characters; i++) {
					addCharEntry();
				}
				builder.append("MAX_CHARACTERS - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case WARP_TO_MAP:
				builder.append("CHANNEL_INDEX - Int(4) - " + slea.readInt() + NEW_LINE);
				int warpType = slea.readInt();
				if (warpType == 2) {
					builder.append("WARP_TYPE - Int(4) - " + warpType + " (" + "CHANGE_MAP)" + NEW_LINE);
					builder.append("MAP_ID - Int(4) - " + slea.readInt() + NEW_LINE);
					builder.append("SPAWN_POINT - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("CHARACTER_HP - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("QUEST_MASK - Long(8) - " + slea.readLong() + NEW_LINE);
				} else {
					builder.append("TODO" + NEW_LINE);
				}
				break;
			//case ZAKUM_SHRINE:
			//	builder.append("TICKS - Byte(1) - " + slea.readByte() + NEW_LINE);
			//	builder.append("TIME_LEFT - Int(4) - " + slea.readInt() + NEW_LINE);
			//	break;
			case SERVERMESSAGE:
				int messageType = slea.readByte();
				String messageTypeStr = "UNKNOWN";
				switch (messageType) {
					case 0:
						messageTypeStr = "Blue Text + [Notice]";
						break;
					case 1:
						messageTypeStr = "Popup";
						break;
					case 2:
						messageTypeStr = "Light Blue Background";
						break;
					case 3:
						messageTypeStr = "Megaphone Message";
					case 4:
						messageTypeStr = "Scolling Marquee Messsage";
						break;
					case 5:
						messageTypeStr = "Pink Text";
						break;
					case 6:
						messageTypeStr = "Blue Text";
				}
				builder.append("MESSAGE_TYPE - Byte(1) - " + messageType + " (" + messageTypeStr + ")" + NEW_LINE);
				long pos = slea.getPosition();
				byte serverMsgMarker = slea.readByte();
				if (serverMsgMarker == 1) {
					builder.append("SERVER_MESSAGE_MARKER - Byte(1) - " + serverMsgMarker + NEW_LINE);
				} else {
					slea.seek(pos);
				}
				builder.append("MESSAGE - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				if (messageType == 3) {
					builder.append("CHANNEL_INDEX - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("SMEGA_EAR - Byte(1) - " + slea.readByte() + NEW_LINE);
				}
				break;
			default:
				//NOTHING? YET!
				builder.append("Un-Analyzable Packet" + NEW_LINE);
				break;
		}*/
                //</editor-fold>
		return builder;
	}

	public StringBuilder handleToServer(RecvPacketOpcode opcode) {
		builder.append("Header : " + HexTool.getOpcodeToString((short) opcode.getValue()) + " ( " + opcode.name() + " ) " + NEW_LINE);
		//<editor-fold defaultstate="collapsed" desc=" Switch Opcode ">
                /*switch (opcode) {
			case PONG:
			//case RELOG:
			case SERVERLIST_REQUEST:
			//case SERVERLIST_REREQUEST:
			case ENTER_CASH_SHOP:
			case ENTER_MTS:
			case CLOSE_CHALKBOARD:
				//NOTHING
				break;
			case LOGIN_PASSWORD:
				builder.append("USERNAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("PASSWORD - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				break;
			case CHECK_CHAR_NAME:
				builder.append("PLAYER_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				break;
			case CHARLIST_REQUEST:
				builder.append("SERVER - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("CHANNEL - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case DELETE_CHAR:
				builder.append("IDATE - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			/*case REGISTER_PIN:
				builder.append("PIN_STATUS - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("PIN - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				break;
			case AFTER_LOGIN: {
				byte c2 = slea.readByte();
				byte c3 = slea.readByte();
				if (c2 == 1 && c3 == 1) {
					builder.append("ACTION - REQUEST_PIN" + NEW_LINE);
					builder.append("C2 - Byte(1) - " + c2 + NEW_LINE);
					builder.append("C3 - Byte(1) - " + c3 + NEW_LINE);
				} else if (c2 == 1 && c3 == 0) {
					builder.append("ACTION - ENTER_PIN" + NEW_LINE);
					builder.append("C2 - Byte(1) - " + c2 + NEW_LINE);
					builder.append("C3 - Byte(1) - " + c3 + NEW_LINE);
					builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
					builder.append("PIN - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				}
				break;
			}*
			case SERVERSTATUS_REQUEST:
				builder.append("WORLD_ID - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case CHAR_INFO_REQUEST:
				builder.append("UNKNOWN - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("UNKNOWN - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("IS_SELF - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case CREATE_CHAR:
				builder.append("NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("FACE - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("HAIR - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("HAIR_COLOR - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("SKIN_COLOR - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("TOP_EQUIP - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("BOTTOM_EQUIP - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("WEAPON_EQUIP - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("GENDER - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("STR - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("DEX - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("INT - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("LUK - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case CLIENT_ERROR:
				builder.append("ERROR - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				break;
			case COUPON_CODE:
				builder.append("UNKNOWN - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("COUPON_CODE - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				break;
			case DENY_PARTY_REQUEST:
				builder.append("COMMAND - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("NAME_FROM - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("NAME_TO - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				break;
			case DISTRIBUTE_AP:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				MapleStat stat = MapleStat.getByValue(slea.readInt());
				//builder.append("UPDATED_STAT - Int(4) - " + Integer.toHexString(stat.getValue()).toUpperCase() + "(" + stat.name() + ")" + NEW_LINE);
				break;
			case DISTRIBUTE_SP:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("UPDATED_SKILL - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case USE_DOOR:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("BACKWARP - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case FACE_EXPRESSION:
				int emoteId = slea.readInt();
				builder.append("EMOTE_ID - Int(4) - " + emoteId + "(" + (emoteId + 5159992) + ")" + NEW_LINE);
				break;
			case GENERAL_CHAT:
				builder.append("CHAT_TEXT - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
				builder.append("BUBBLE_ONLY - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case CHANGE_KEYMAP:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				int keysChanged = slea.readInt();
				builder.append("KEYS_CHANGED - Int(4) - " + keysChanged + NEW_LINE);
				for (int i = 0; i < keysChanged; i++) {
					builder.append("   KEY - Int(4) - " + slea.readInt() + NEW_LINE);
					builder.append("   TYPE - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("   ACTION - Int(4) - " + slea.readInt() + NEW_LINE + NEW_LINE);
				}
				break;
			case MESO_DROP:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("MESOS - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			//case OBJECT_REQUEST:
			//	builder.append("MAP_ID - Int(4) - " + slea.readInt() + NEW_LINE);
			//	builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
			//	break;
			case MOVE_PLAYER:
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				parseMovement();
				break;
			case MOVE_LIFE:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("MOVE_ID - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("SKILL_BYTE - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("SKILL_1 - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("SKILL_ID - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("SKILL_LEVEL - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("SKILL_DELAY - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("UNKNOWN - BYTE[](5) - " + HexTool.toString(slea.read(5)) + NEW_LINE);//byte -> int
				builder.append("START_X - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("START_Y - Short(2) - " + slea.readShort() + NEW_LINE);
				parseMovement();
				break;
			case MOVE_PET:
				builder.append("PET_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("X - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("Y - Short(2) - " + slea.readShort() + NEW_LINE);
				parseMovement();
				break;
			case MOVE_SUMMON:
				builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("X - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("Y - Short(2) - " + slea.readShort() + NEW_LINE);
				parseMovement();
				break;
			case USE_UPGRADE_SCROLL:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("SLOT - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("DESTINATION - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("WHITE_SCROLL - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case USE_SKILL_BOOK:
			case USE_SUMMON_BAG:
			case USE_MOUNT_FOOD:
			//case USE_PET_FOOD:
			case USE_ITEM:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("SLOT - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case USE_ITEMEFFECT:
			case USE_CHAIR:
			case CANCEL_ITEM_EFFECT:
				builder.append("ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case USE_CASH_ITEM:
				builder.append("MODE - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				//TODO - HANDLE ALL ITEMS
				break;
			case TAKE_DAMAGE:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				byte damageFrom = slea.readByte();
				builder.append("DAMAGE_FROM - Byte(1) - " + damageFrom + NEW_LINE);
				builder.append("ELEMENT - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("DAMAGE - Int(4) - " + slea.readInt() + NEW_LINE);
				if (damageFrom != -2) {
					builder.append("MONSTER_ID_FROM - Int(4) - " + slea.readInt() + NEW_LINE);
					builder.append("OBJECT_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				}
				break;
			case SPECIAL_MOVE:
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("UNKNOWN - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("SKILL_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("SKILL_LEVEL - Byte(1) - " + slea.readByte() + NEW_LINE);
				if (slea.available() == 4) {
					builder.append("X - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y - Short(2) - " + slea.readShort() + NEW_LINE);
				} else {
					//TODO (Monster Magnet)
				}
				break;
			case SPAWN_PET:
				builder.append("UNKNOWN - Int(4) - " + slea.readInt() + NEW_LINE);
				builder.append("SLOT - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("LEAD - Byte(1) - " + slea.readByte() + NEW_LINE);
				break;
			case HEAL_OVER_TIME:
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("UNKNOWN - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("UNKNOWN - Byte(1) - " + slea.readByte() + NEW_LINE);
				builder.append("HEAL_HP - Short(2) - " + slea.readShort() + NEW_LINE);
				builder.append("HEAL_MP - Short(2) - " + slea.readShort() + NEW_LINE);
				break;
			case CANCEL_CHAIR: {
				int mode = slea.readShort();
				builder.append("TYPE - Short(2) - " + (mode == -1 ? "CANCEL_CHAIR" : "IN_MAP_CHAIR") + "(" + mode + ")" + NEW_LINE);
				break;
			}
			case CANCEL_BUFF:
				builder.append("SKILL_ID - Int(4) - " + slea.readInt() + NEW_LINE);
				break;
			case BUDDYLIST_MODIFY: {
				int mode = slea.readByte();
				String modeStr = "";
				switch (mode) {
					case 1:
						modeStr = "ADD";
						break;
					case 2:
						modeStr = "ACCEPT BUDDY";
						break;
					case 3:
						modeStr = "DELETE BUDDY";
						break;
				}
				builder.append("MODE - Byte(1) - " + modeStr + "(" + mode + ")" + NEW_LINE);
				switch (mode) {
					case 1:
						builder.append("ADD_CHARACTER_NAME - MapleAsciiString - " + slea.readMapleAsciiString() + NEW_LINE);
						break;
					case 2:
					case 3:
						builder.append("BUDDY_CID - Int(4) - " + slea.readInt() + NEW_LINE);
						break;

				}
				break;
			}
			case STORAGE:
				int command = slea.readByte();
				builder.append("COMMAND - Byte(1) - " + command + "(");
				switch (command) {
					case 4://TAKE OUT
						builder.append("TAKE OUT)" + NEW_LINE);
						builder.append("TYPE - Byte(1) - " + slea.readByte() + NEW_LINE);
						builder.append("SLOT - Byte(1) - " + slea.readByte() + NEW_LINE);
						break;
					case 5://STORE
						builder.append("STORE)" + NEW_LINE);
						builder.append("SLOT - Short(2) - " + slea.readShort() + NEW_LINE);
						builder.append("ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
						builder.append("QUANTITY - Short(2) - " + slea.readShort() + NEW_LINE);
						break;
					case 6://ARRANGE
						builder.append("ARRANGE)" + NEW_LINE);
						break;
					case 7://MESO
						builder.append("MESOS)" + NEW_LINE);
						builder.append("MESOS - Int(4) - " + slea.readInt() + NEW_LINE);
						break;
					case 8://CLOSE
						builder.append("CLOSE)" + NEW_LINE);
						break;
				}
				break;
			default:
				builder.append("Un-Analyzable Packet" + NEW_LINE);
				break;
		}*/
                //</editor-fold>
		return builder;
	}

	public void addCharStats() {
		builder.append("CHARACTER_ID - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("CHARACTER_NAME - AsciiString(13) - " + slea.readAsciiString(13) + NEW_LINE);
		builder.append("GENDER - Byte(1) - " + slea.readByte() + NEW_LINE);
		MapleSkinColor skinColor = MapleSkinColor.getById(slea.readByte());
		builder.append("SKIN_COLOR - Byte(1) - " + skinColor.getId() + " (" + skinColor.name() + ")" + NEW_LINE);
		builder.append("FACE - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("HAIR - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("TICKS - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("TICKS - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("TICKS - Long(8) - " + slea.readLong() + NEW_LINE);
		builder.append("TICKS - Long(8) - " + slea.readLong() + NEW_LINE);
		builder.append("LEVEL - Byte(1) - " + slea.readByte() + NEW_LINE);
		MapleJob job = MapleJob.getById(slea.readShort());
		builder.append("JOB_ID - Short(2) - " + job.getId() + " (" + job.name() + ")" + NEW_LINE);
		builder.append("STR - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("DEX - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("INT - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("LUK - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("HP - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("MAX_HP - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("MP - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("MAX_MP - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("AP - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("SP - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("EXP - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("FAME - Short(2) - " + slea.readShort() + NEW_LINE);
		builder.append("UNK(V62) - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("MAP_ID - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("INITIAL_SPAWN_POINT - Byte(1) - " + slea.readByte() + NEW_LINE);

	}

	public void addCharLook() {
		builder.append("GENDER - Byte(1) - " + slea.readByte() + NEW_LINE);
		MapleSkinColor skinColor = MapleSkinColor.getById(slea.readByte());
		builder.append("SKIN_COLOR - Byte(1) - " + skinColor.getId() + " (" + skinColor.name() + ")" + NEW_LINE);
		builder.append("UNK(V62) - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("FACE - Int(4) - " + slea.readInt() + NEW_LINE);
		builder.append("NOT_MEGAPHONE - Byte(1) - " + slea.readByte() + NEW_LINE);
		builder.append("HAIR - Int(4) - " + slea.readInt() + NEW_LINE);
		byte entry = slea.readByte();
		while (entry != 0xFF) {
			builder.append("SLOT - Byte(1) - " + entry + NEW_LINE);
			builder.append("ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
			entry = slea.readByte();
		}
		builder.append("END_OF_VISIBLE_ITEMS - Byte(1) - " + entry + NEW_LINE);
		entry = slea.readByte();
		while (entry != 0xFF) {
			builder.append("SLOT - Byte(1) - " + entry + NEW_LINE);
			builder.append("ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
			entry = slea.readByte();
		}
		builder.append("END_OF_MASKED_ITEMS - Byte(1) - " + entry + NEW_LINE);
		builder.append("CASH_WEAPON_ID - Int(4) - " + slea.readInt() + NEW_LINE);
		for (int i = 1; i <= 3; i++) {
			builder.append("PET_" + i + "_ITEM_ID - Int(4) - " + slea.readInt() + NEW_LINE);
		}
	}

	public void addCharEntry() {
		addCharStats();
		addCharLook();
		byte rankEnabled = slea.readByte();
		builder.append("RANK_ENABLED - Byte(1) - " + rankEnabled + NEW_LINE);
		if (rankEnabled == 1) {
			builder.append("RANK - Int(4) - " + slea.readInt() + NEW_LINE);
			builder.append("RANK_MOVE - Int(4) - " + slea.readInt() + NEW_LINE);
			builder.append("JOB_RANK - Int(4) - " + slea.readInt() + NEW_LINE);
			builder.append("JOB_RANK_MOVE - Int(4) - " + slea.readInt() + NEW_LINE);
		}

	}

	public void parseMovement() {
		byte numCommands = slea.readByte();
		builder.append("NUM_COMMANDS - Byte(1) - " + numCommands + NEW_LINE);
		for (int i = 0; i < numCommands; i++) {
			byte command = slea.readByte();
			builder.append("COMMAND - Byte(1) - " + command + NEW_LINE);
			switch (command) {
				case 0: //NORMAL MOVE
				case 5: //PET MOVE?
				case 17: //FLOAT - 2
				{
					builder.append("X_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("X_WOBBLE - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_WOBBLE - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("UNK - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("NEW_STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("DURATION - Short(2) - " + slea.readShort() + NEW_LINE);
					break;
				}
				case 1: //JUMPING
				case 2: //JUMPING/KNOCKBACK
				case 6: //FLASH JUMP
				case 13: //STEP BACK
				case 12: //HORNTAIL KNOCKBACK
				case 16: //FLOAT - 1
				{
					builder.append("X_MOD - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_MOD - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("NEW_STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("DURATION - Short(2) - " + slea.readShort() + NEW_LINE);
					break;
				}
				case 3:
				case 4: //TELEPORT
				case 7: //ASSUALTER
				case 8: //ASSASINATE
				case 9: //RUSH
				{
					builder.append("X_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("X_WOBBLE - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_WOBBLE - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("NEW_STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
					break;
				}
				case 10: //CHANGE EQUIP
				{
					builder.append("SLOT - Byte(1) - " + slea.readByte() + NEW_LINE);
					break;
				}
				case 11: //CHAIR
				case 14: //JUMP DOWN - 1
				{

					builder.append("X_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("UNK - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("NEW_STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("DURATION - Short(2) - " + slea.readShort() + NEW_LINE);
					break;
				}
				case 15: //JUMP DOWN - 2
				{
					builder.append("X_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_POS - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("X_WOBBLE - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("Y_WOBBLE - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("UNK - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("FH - Short(2) - " + slea.readShort() + NEW_LINE);
					builder.append("NEW_STATE - Byte(1) - " + slea.readByte() + NEW_LINE);
					builder.append("DURATION - Short(2) - " + slea.readShort() + NEW_LINE);
					break;
				}
				default: {
					builder.append("Unknown Movement Command: " + command + " : Ending structure" + NEW_LINE);
					return;
				}
			}
		}
	}

	public boolean isThrowingStar(int itemId) {
		return itemId >= 2070000 && itemId < 2080000;
	}

	public boolean isBullet(int itemId) {
		return itemId >= 2330000 && itemId < 2340000;
	}

	public boolean isRechargable(int itemId) {
		return isBullet(itemId) || isThrowingStar(itemId);
	}
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton closeButton;
    private javax.swing.JButton copyStructureButton;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel packetLabel;
    private javax.swing.JTextArea packetStructureTextArea;
    // End of variables declaration//GEN-END:variables
}
